/**
 * Desenvolvido pela Fábrica de Software do CESUPA.
 * Todos os direitos reservados.
 */
package br.cesupa.fabsoft.nomedoprojeto.modules.systemmodule.dataaccess;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Breno Leite
 */
public class Message implements Cloneable {

    private String text;
    private MessageType messageType = MessageType.INFO;
    private Map<String, String> fields = new HashMap<String, String>();

    /**
     * Creates a message without details.
     *
     * @param text  the message´s text
     * @param messageType   the message´s type
     */
    public Message(String text, MessageType messageType) {
        setText(text);
        setMessageType(messageType);
    }

    /**
     * Creates a info message with a given text.
     * 
     * @param text  the message´s text
     */
    public Message(String text) {
        setText(text);
        setMessageType(MessageType.INFO);
    }

    public void createField(String fieldName, String fieldValue) {
        getFields().put(fieldName, fieldValue);
    }

    public Message createClone() {
        try {
            return (Message) this.clone();
        } catch (CloneNotSupportedException exception) {
            return null;
        }
    }

    /**
     * @return the messageType
     */
    public MessageType getMessageType() {
        return messageType;
    }

    /**
     * @param messageType the messageType to set
     */
    public void setMessageType(MessageType messageType) {
        this.messageType = messageType;
    }

    /**
     * @return the text
     */
    public String getText() {
        return text;
    }

    /**
     * @param text the text to set
     */
    public void setText(String text) {
        this.text = text;
    }

    /**
     * @return the fields
     */
    public Map<String, String> getFields() {
        return fields;
    }

    /**
     * @param fields the fields to set
     */
    public void setFields(Map<String, String> fields) {
        this.fields = fields;
    }
}
